package cn.bytecollege.service;

import cn.bytecollege.dao.OrderDao;
import cn.bytecollege.entity.Page;
import cn.bytecollege.entity.UserManage;

import java.util.List;

public class OrderService {
    OrderDao orderDao=null;
    public OrderService(){
        orderDao=new OrderDao();
    }
    /**
     * 查询所有订单
     * zxy
     */
    public Page<UserManage> findListByPage(int pageIndex, int pageSize){
        List<UserManage> list = orderDao.findListByPage(pageIndex, pageSize);
        //查询总条数
        int count = orderDao.count();
        Page<UserManage> page = new Page<>();
        page.setCurrentIndex(pageIndex);
        page.setList(list);
        page.setTotal(count);
        page.setTotalPage(count);
        page.setPageSize(pageSize);
        page.setPageIndex();
        return page;
    }
    /**
     * 根据用户名模糊查询订单
     * zxy
     */
    public Page<UserManage> findListByName(int pageIndex, int pageSize,String username) {
        List<UserManage> list = orderDao.findListByName(pageIndex, pageSize,username);
        //查询总条数
        int count = orderDao.countByName(username);
        Page<UserManage> page = new Page<>();
        page.setCurrentIndex(pageIndex);
        page.setList(list);
        page.setTotal(count);
        page.setTotalPage(count);
        page.setPageSize(pageSize);
        page.setPageIndex();
        return page;
    }
}
